﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AspNetCs.Common;
using AspNetCs.Bll;
using AspNetCs.Model;
using AspNetCs.Enumerations;
using AspNetCs.Enumerations.Channel_Enum;
using System.Data;

public partial class Users_NetMuManage :BasePage
{
    protected int id = 0;
    protected NetMuBLL bll = new NetMuBLL();
    protected NetMu_Model model = new NetMu_Model();
    //protected Memorial MemorialBll = new Memorial();
    //protected memorial_model MemorialModel = new memorial_model();

    protected string notSet = "display:none;";
    protected string play = "display:block;";
    protected string musicPath = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUserExit("Login.Aspx?ReUrl=" + configInfo.InstallDir + "Users/NetMuManage.aspx", "请您登录", true);
        if(!IsPostBack)
        {

            if (Request["id"] != null)
            {
                id = StringHelper.isNumber_int(Request["id"].ToString());
                ViewState["id"] = Request["id"];
            }
            if (id <= 0)
            {
                ShowMsgBack("参数传递错误！");
                Response.End();
            }
            model = bll.getNetMuDetailInfo(id);

            MusicBLL musicBLL = new MusicBLL();
            musicBLL.BindSelectedMusic(model.MusicId, ddlMusic);
            //Response.Write(model.GetPwd);

            Base_CurrPath = Base_CurrPath + " >> 会员管理中心 >> 公墓管理 >>首页";
            CheckUserExit("Login.Aspx?ReUrl=" + configInfo.InstallDir + "Users/NetMuManage_" + id + ".Aspx", "", true);
            
        }
        else
        {
            if (ViewState["id"]!=null)
            {
                id = StringHelper.isNumber_int(ViewState["id"].ToString());
                model = bll.getNetMuDetailInfo(id);
            }
        }
        initMusic();

    }

    public void initMusic()
    {
        if (model.MusicId == 0)
        {
            notSet = "display:block;";
            play = "display:none;";
        }
        else
        {
            MusicBLL musicBll = Music_Bll.CreateNew;
            MusicModel musicModel = new MusicModel();
            DataTable dataTable = musicBll.GetDataTable("id=" + model.MusicId);
            if (dataTable.Rows.Count > 0)
            {
                musicModel = musicBll.GetModel(dataTable.Rows[0]);
            }
            if (musicModel.MusicType == 0)
            {
                musicPath = "../" + musicModel.MusicPath;
            }
            else
            {
                musicPath = musicModel.MusicPath;
            }
        }
    }

    protected void btnMusic_Click(object sender, EventArgs e)
    {
        int MusicId = StringHelper.isNumber_int(ddlMusic.SelectedValue);
        //if (MusicId > 0)
        //{
            bll.SetMusic(id, MusicId);
        //}
            Response.Redirect("NetMuManage_" + id + ".Aspx");
    }

   
}
